package cn.com.scitc.pano.controller;


import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.File;


@Controller
@RequestMapping("/")
public class HomeController {
    private Log log = LogFactory.getLog(getClass());

    @GetMapping("/include/navstyle")
    public String navstyle(){
        return "/include/navstyle";
    }

    @RequestMapping("/select")
    private String select(Model model) {
        UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        String name = userDetails.getUsername();
        File file = new File("D:/code/pano/src/main/resources/static/images/rotPhoto/" + name);
        if (!file.exists()){
            model.addAttribute("goods","/prompt");
        }else {
            model.addAttribute("goods","/goods");
        }
        if (!file.exists()){
            model.addAttribute("works","/prompt");
        }else {
            model.addAttribute("works","/userwork");
        }
        return "select";
    }
//
    @RequestMapping("/include/nav")
    private String nav() {
        return "/include/nav";
    }

    @RequestMapping("/include/footer")
    private String footer() {
        return "/include/footer";
    }

    @RequestMapping("/prompt")
    private String prompt() {
        return "/prompt";
    }


    }

